<{include file="public_html/header.html"}>
<{include file="public_html/left_menu.html"}>
	<!-- content starts -->
	<blockquote class="layui-elem-quote"><{$action}></blockquote>

	<fieldset class="layui-elem-field">
  		<legend>按条件搜索</legend>
  		<div class="layui-field-box">
			<form class="layui-form layui-form-pane1" method="post" action="<{$current_url}>">
				<div class="layui-form-item">
			    	<div class="layui-inline">
			    		<input type="text" name="school_name" placeholder="网校名称" value="<{if isset($conditions['school_name']) AND $conditions['school_name'] != 0}><{$conditions['school_name']}><{/if}>" class="layui-input">
			    	</div>

		            <div class="layui-inline">
			            <select name="status" class="category_pid">
			              	<option value="9" <{if $conditions['status'] == 9}>selected<{/if}>>审核状态</option>
		                	<option value="0" <{if $conditions['status'] == 0}>selected<{/if}>>等待审核</option>
		                	<option value="1" <{if $conditions['status'] == 1}>selected<{/if}>>审核通过</option>
		                	<option value="2" <{if $conditions['status'] == 2}>selected<{/if}>>审核拒绝</option>
					  	</select>
				  	</div>

				  	<div class="layui-inline">
			            <select name="agent_id">
			              	<option value="0" <{if $conditions['agent_id'] == 0}>selected<{/if}>>按代理商筛选</option>
			              	<{foreach from=$agent_list item=$agent}>
			              	<option value="<{$agent.id}>" <{if $conditions['agent_id'] == $agent.id}>selected<{/if}>><{$agent.name}></option>
			              	<{/foreach}>
					  	</select>
				  	</div>

			    	<div class="layui-inline">
			    		<button type="submit" class="layui-btn">搜索</button>
			    	</div>
		    	</div>
			</form>
  		</div>
	</fieldset>
	<form class="layui-form layui-form-pane1" method="post" delete_action="/school/delete">
		<table class="layui-table" lay-even lay-skin="row">
		  	<thead>
			  	<tr>
				  	<th>ID</th>
				  	<th>网校名称</th>
				  	<th>代理商</th>
				  	<th>网校地址</th>
				  	<th>运营状态</th>
				  	<th>审核状态</th>
				  	<th>操作</th>
			  	</tr>
		  	</thead>
		  	<tbody>
		  	<{foreach from=$school_list item=item}>
			  	<tr>
			  		<td class="center">
						<input type="checkbox" name="ids[]" value="<{$item['id']}>" title="<{$item['id']}>">
			  		</td>
			  		<td class="center"><{$item['school_name']}></td>
			  		<td class="center"><{$item['name']}></td>
			  		<td class="center"><{$item['province_name']}> <{$item['city_name']}> <{$item['area_name']}> <{$item['school_address']}></td>
			  		<td class="center"><{if $item['run_status'] == 1}>运营中<{else}>停止运营<{/if}></td>
			  		<td class="center"><{if $item['status'] == 0}>等待审核<{elseif $item['status'] == 1}>审核通过<{else}>审核拒绝<{/if}></td>
			  		<td class="center">
						<a class="layui-btn layui-btn-primary layui-btn-small" href="/school/edit/<{$item['id']}>" target="_blank"><i class="layui-icon"></i></a>
						<a class="layui-btn layui-btn-primary layui-btn-small delete_data" href="/school/delete/<{$item['id']}>"><i class="layui-icon"></i></a>
						<{if $item.agent_id <= 0}>
						<a class="layui-btn layui-btn-primary layui-btn-small dls" href="javascript:;" school_id="<{$item['id']}>" target="_blank">设为代理商</a>
						<{/if}>
					</td>
			  	</tr>
		  	<{/foreach}>
		  	<{if $school_list|count eq 0}>
		  		<tr>
			  		<td class="center" style=" height:120px; text-align:center;line-height:120px;" colspan="8">
						赞无数据！
					</td>
			  	</tr>
		  	<{/if}>
		  	<tr>
				<td class="center" colspan="7">
					<input type="checkbox" lay-filter="checkbox_all" title="全选">
					<button id="delete" class="layui-btn layui-btn-primary layui-btn-small" style="margin-top:4px;"><i class="layui-icon"></i> 批量删除</button>
				</td>
			</tr>
	  		</tbody>
	  	</table>
  	</form>
  	<div class="layui-box layui-laypage layui-laypage-default">
		<{$pagination}>
	</div>

<{include file="public_html/footer.html"}>
<script>
	layui.use(['form', 'jquery', 'layedit'], function(){
        var layedit = layui.layedit,form = layui.form(),$ = layui.jquery;
        $(".dls").click(function(){
            var _this = $(this);
            var school_id = $(this).attr("school_id");
            layer.prompt({title: '请设置该学校的扣点百分比', formType: 3}, function(text, index){
                if(isNaN(text)){
                    layer.msg("时长必须是数字！", {icon:5, anim: 1});
                    return false;
                }
                layer.close(index);
                $.ajax({
                    type: "POST",
                    url: "/agent/add_school_agent",
                    dataType:"json",
                    data:{'school_id':school_id, 'points':text},
                    success: function(result){
                        // layer.close(ii);
                        if(result.code == 0){
                            layer.msg('不能重复设置', {icon:5});
                        }else if(result.code == 1){
                            layer.msg('设置成功', {icon:6});
                            _this.remove();
                        }
                    }
                });
            });
        })

    });
</script>